package com.northwind.util;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

public class EasyPOIUtil {
    /**导出
     * 大标题名，目录名,导出的实体类对象，要导出的数据集合
     * */
    public static void export(String title, String catalogue, Class object, List list,String fileNameAndPath){
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title,catalogue),object,list);
        //导出位置
        try {
            workbook.write(new FileOutputStream(new File(fileNameAndPath)));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
